<template>
    <div class="">
      登录中...请稍等
    </div>
</template>

<script>
    import {getUUID} from '@/utils'
    import router from "../../router";
    const ls = window.sessionStorage;

    export default {
        data() {
            return {
            }
        },
        created() {
          window.sessionStorage.clear();
          this.getLogin();
        },
        methods: {
          getLogin () {
            let codestr = this.getQueryVariable('code')
            this.code = codestr
            console.info(this.code)
            this.$http({
              url: this.$http.adornUrl('/service/wwlogin?code='+codestr),
              method: 'get'
            }).then(({data}) => {
              debugger
              if (data && data.code === '000000') {
                ls.setItem('Token', data.token)
                this.$router.replace({name: 'home'})
              } else {
                //this.getCaptcha()
                this.$message.error(data.msg)
                // 跳转到
                //this.router.push("/login")
                this.$router.push({path:'/home'})
              }
            })
          },
          getQueryVariable(pname){
            var query = window.location.search;
            var query2 = window.location.hash;
            if(query == ''){
              query = query2
            }
            if(query.indexOf("?") > 0){
              query = query.substr(query.indexOf("?") + 1);
            }
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
              var pair = vars[i].split("=");
              if(pair[0] == pname){
                return pair[1];
              }
            }
            return "";
          },
        }
    }
</script>
